<template>
	<div class="record-bg u-page">
		<u-navbar :title="title" :custom-back="comeBackCustom" :back-icon-name="backIconName" :border-bottom="false" title-width="380"></u-navbar>
		<div>
				<div class="u-pb-10 u-pl-10 u-pr-10" style="background-color: #ffffff;" v-if="logisticsDynamic.ftime">
					<div class="u-text-center u-fz-15 u-pt-5" v-if="automaticReceiptDays">剩余{{automaticReceiptDays?automaticReceiptDays:''}}天自动确认收货</div>
					<div class="u-flex u-pt-10" @click="toLogisticsInfo">
						<div class="car-icon"></div>
						<div style="display: flex;flex-direction: column;;justify-content: center;width: 85%;">
							<div style="overflow: hidden;text-overflow: ellipsis;white-space: nowrap;font-size: 32rpx;color: #5dc710;">{{logisticsDynamic.context}}</div>
							<div style="color: #bcbcbc;">{{logisticsDynamic.ftime}}</div>
						</div>
						<div class="right-icon u-pl-5"></div>
					</div>
				</div>
				
				<div class="bg-white u-pb-15">
					<div class="u-border-top u-pt-15" style="width: 93%;margin: 0 auto;">
						<div style="display: flex;justify-content: space-between;align-items: center;">
							<div class="cont-right">
								<div class="u-flex u-fz-13">
									<span v-if="addressObj.DefaultStatus == 1">
										<div class="default-tag">默认</div>
									</span>
									<span class='address1'>{{addressObj.Region.replace(/'-'/g, '')}}-{{addressObj.StreetVillage.replace(/'-'/g, '')}}</span>
								</div>
								<div class="u-title u-fz-20 u-pt-5" v-if="addressObj.Address">{{addressObj.Address}}</div>
								<div class="u-pt-5 u-fz-15">
									<span>{{addressObj.Name}}</span>
									<span class="u-pl-5">{{addressObj.PhoneNum}}</span>
								</div>
							</div>
						</div>
					</div>
				</div>

				<div class="bg-white border-radius-30 u-pb-15">
					<div class="aui-flex1 u-mt-10 u-pt-15" @click="toGoodsDetails">
						<div class="aui-flex-goods">
							<img :src="goods.goodsImages.split(',')[0]" alt="">
						</div>
						<div class="aui-flex-box">
							<div class="goods-title">
								{{form.goodsName?form.goodsName:''}}
							</div>
							<div class="goods-specification">{{form.specification?form.specification:'暂无规格'}}</div>
							<div style="padding-top: 15rpx;">
								<u-tag text="商品团购" color="#dc6e00" border-color="#dc6e00" bg-color="#ffffff" size="mini" mode="light" />
							</div>
						</div>
					</div>
					<!-- <div class="u-pr-25" style="display: flex;flex-direction: row-reverse;">
						<div class="u-flex u-fz-15">
							<div>共{{form.buyQuantity?form.buyQuantity:0}}件</div>
							<div class="u-pl-5">
								实付：<span class="u-title">&yen;{{form.payAmount?form.payAmount:'0.00'}}</span>
							</div>
						</div>
					</div> -->
					
					<div class="aui-flex2 aui-choice-white b-line">
						<div class="aui-flex-box">商品总价</div>
						<div class="aui-flex-triangle">&yen;{{form.originalPayAmount}}</div>
					</div>
					<div class="aui-flex2 aui-choice-white b-line">
						<div class="aui-flex-box">运费</div>
						<div class="aui-flex-triangle">&yen;0.00</div>
					</div>
					<div class="aui-flex2 aui-choice-white b-line">
						<div class="aui-flex-box">优惠券</div>
						<div class="aui-flex-triangle">-&yen;{{form.couponAmount}}</div>
					</div>
					<div class="aui-flex2 aui-choice-white b-line">
						<div class="aui-flex-box">钱包抵扣金额</div>
						<div class="aui-flex-triangle">-&yen;{{form.deductionAmount}}</div>
					</div>
					<div class="aui-flex2 aui-choice-white b-line">
						<div class="aui-flex-box">实付款</div>
						<div class="aui-flex-triangle cont-red">&yen;{{form.payAmount}}</div>
					</div>
				</div>

				<!-- 订单信息 -->
				<div class="bg-white u-mt-10 u-mb-10 border-radius-30">
					<div>
						<div class="aui-flex aui-choice-white flex-end">
							<div class="aui-flex-box">备注</div>
							<div class="u-fz-15">
								{{form.orderRemarks?form.orderRemarks:''}}
							</div>
						</div>

						<div class="aui-flex aui-choice-white">
							<div class="aui-flex-box">分享3人返现</div>
							<div class="cont-red u-fz-15" v-if="ShareProgress.completedTimes == ShareProgress.taskTimes">
								<span>已收入&yen;{{totalShareReward?totalShareReward:0}}</span>
							</div>
							<div class="cont-red u-fz-15" v-else>
								<span style="text-decoration: underline;" @click="createPoster(shareData.docUnid,shareData.shareAddress,shareData.route,shareData.style,shareData.taskTimes,shareData.posterData)">立即分享</span>得&yen;{{totalShareReward?totalShareReward:0}}
							</div>
						</div>

						<div class="aui-flex aui-choice-white" @click="goToIncomeIndex" v-if="isCreator">
							<div class="aui-flex-box">代理分销佣金</div>
							<div class="cont-red u-fz-15">
								已收入&yen;{{goods.foremanReward?goods.foremanReward:0}}
							</div>
						</div>

						<div class="aui-flex aui-choice-white">
							<div class="aui-flex-box">附近区域服务商</div>
							<div class="cont-gray u-fz-15">
								{{supplier.providerId?('NO.'+supplier.providerId):''}}
							</div>
						</div>
						
						<div class="aui-flex aui-choice-white">
							<div class="aui-flex-box">订单编号</div>
							<!-- <div class="cont-gray u-fz-15">
								<text user-select='true'>{{form.orderId?form.orderId:''}}</text>
							</div> -->
							<div class="cont-gray u-fz-15 u-flex">
								<div class="order-id">
									{{form.orderId?form.orderId:''}}
								</div>
								<span class="copy-btn" @click="longpressCopy(form.orderId,'已复制')">复制</span>
							</div>
						</div>	
						
						<div class="aui-flex aui-choice-white">
							<div class="aui-flex-box">下单时间</div>
							<div class="cont-gray u-fz-15">
								{{form.joinTime?form.joinTime:''}}
							</div>
						</div>

					</div>
				</div>
				
				<!-- 评论 -->
				<div class="bg-white u-mt-10 u-mb-100 u-pb-10 border-radius-30" v-if="form.evaluationContent">
					<div class="comment-title">评论</div>
					<div style="width: 90%;margin: 0 auto;">
						<div class="u-pt-15 u-pb-15 u-pl-10">{{form.evaluationContent}}</div>
						<div class="pictrues-box u-pl-5" v-if="form.evaluationPictures">
							<div v-for="(item,index) in evaluationPicturesArr" :key="index" style="padding: 10rpx;position: relative;" @click="previewPictrueOrVideo(item,'png')">
								<u-image width="200rpx" height="200rpx" :src="item"></u-image>
							</div>
						</div>
					</div>
				</div>
				
				<div style="height: 300rpx;" v-if="logisticsDynamic.ftime"></div>
				<div style="height: 150rpx;" v-else></div>
				
				<!-- 按钮 -->
				<div style="position: fixed;bottom: 0rpx;background-color: #FFFFFF;width: 100%;z-index: 3;">
					<div class="notice-bar" v-if="isConsumerOfOrder">
						<span style="text-decoration: underline;" @click="showOfficialAccount">关注公众号</span>，完成分享任务立即返现¥{{totalShareReward?totalShareReward:'0'}}，<span style="text-decoration: underline;" @click="createPoster(shareData.docUnid,shareData.shareAddress,shareData.route,shareData.style,shareData.taskTimes,shareData.posterData)">当前进度({{ShareProgress.completedTimes?ShareProgress.completedTimes:0}}/{{ShareProgress.taskTimes?ShareProgress.taskTimes:3}})</span>
					</div>
					<div class="u-pt-10 u-pb-30">
						<div class="u-pr-15" style="display: flex;flex-direction: row-reverse;">
							<div>
								<u-button shape="circle" size="mini" :custom-style="customStyle2" @click="toAnotherOrder">再来一单</u-button>
								<u-button shape="circle" size="mini" :custom-style="customStyle2" v-if="title != '已退款'" @click="openCustomerServiceChat">退换/售后</u-button>
								<u-button shape="circle" size="mini" :custom-style="customStyle1" v-if="title == '待收货'" @click="ConfirmReceipt">确认收货</u-button>
								<u-button shape="circle" size="mini" :custom-style="customStyle1" v-if="title == '待评价'" @click="toEvaluate">评价</u-button>
								<u-button shape="circle" size="mini" :custom-style="customStyle3" hover-class="none" v-if="title == '已评价'">已评价</u-button>
							</div>
						</div>
					</div>
				</div>
				
				<!-- 商品返现已到账 -->
				<u-modal v-model="scenario_show" confirm-text="查看收益" title="商品返现已到账" @confirm="goToIncomeIndex">
					<div class="slot-content3">
						<span class="color-red">{{goods.goodsName?goods.goodsName:''}}</span>团购活动已达到品牌返现标准，您参与购买{{form.buyQuantity?form.buyQuantity:''}}件商品，获返现<span class="color-red">¥{{goods.foremanReward?goods.foremanReward:'0'}}</span>元。
					</div>
				</u-modal>
				
				<!-- 关注公众号弹窗 -->
				<u-mask :show="official_account_show" :mask-click-able="false" z-index="9999" mask-click-able="true" @click="closeOfficialAccount">
					<div class="mask-solt">
						<div>
							<div class="official-account-bg"></div>
						</div>
					</div>
				</u-mask>
				
				<!-- 客服 -->
				<u-modal v-model="customerService_show" confirm-text="关闭" title="客服微信">
					<view class="slot-content">
						<rich-text :nodes="this.escape2Html(customerService.topPrompt)"></rich-text>
						<div class="u-center u-pt-5 u-pb-5">
							<u-image width="300rpx" height="300rpx" :src="customerService.csQrCode"
								@longpress="saveImg(csQrCode)"></u-image>
						</div>
						<rich-text :nodes="this.escape2Html(customerService.bottomPrompt)"></rich-text>
					</view>
				</u-modal>
		</div>
		
		<!-- 弹窗生成海报 -->
		<u-modal v-model="poster_modal_show"
			confirm-text="完成3名好友扫码即可返现"
			confirm-color="#eb5468"
			:mask-close-able="true" 
			:show-title="false"
			@confirm="SaveAlbum(PosterURL)">
			<u-image :src="PosterURL" mode="widthFix" @longpress="saveImg(PosterURL)"></u-image>
		</u-modal>

	</div>
</template>

<script>
	import globalData from "@/globalData";
	export default {
		data() {
			return {
				form: {},// 订单信息
				goods: {},// 商品信息
				addressObj: {},// 收货地址
				customerService: {},// 客服信息
				showBtn: false, // 是否显示“前往订单列表”按钮，默认不显示
				automaticReceiptDays: '',// 自动收货剩余天数
				isCreator: false,//当前用户是否为此订单的团长
				isConsumerOfOrder: false,// 当前用户是否为此订单的消费者
				poster_modal_show: false,//海报弹窗显示
				PosterURL: '',//海报地址
				totalShareReward: '',// 消费者总分享报酬
				scenario: '',
				scenario_show: false,
				shareData: {
					docUnid: '',
					shareAddress: '',
					route: '',
					style: 8,
					shareBtnStyle: 'buy-goods-share',
					type: 2,
					taskTimes: 3,
					posterData: {
						imageURL: '', // 商品主图URL地址
						productName: '', // 商品名称
						productPrice: '', // 商品价格
						invitemsg: '邀请您参与平台活动', // 邀请内容。可不传，默认邀请
						type: '',
						giudeText: '长按识别小程序 参与活动',
						priceDesc: '玫丽专享价'
					},
				},
				ShareProgress: {
					completedTimes: 0,
					taskTimes: 3
				},
				title: '订单详情',
				comeback: 0,//自定义返回路径 0为返回上一页，1为返回代理销售列表
				backIconName: 'nav-back',
				customStyle1: {
					borderRadius: '20rpx',
					color: '#eb5468',
					marginLeft: '8rpx',
					fontSize: '28rpx',
					padding: '0rpx 20rpx',
					height: '60rpx',
					lineHeight: '60rpx'
				},
				customStyle2: {
					borderRadius: '20rpx',
					color: '#000000',
					marginLeft: '8rpx',
					fontSize: '28rpx',
					padding: '0rpx 20rpx',
					height: '60rpx',
					lineHeight: '60rpx'
				},
				customStyle3: {
					borderRadius: '20rpx',
					marginLeft: '8rpx',
					fontSize: '28rpx',
					padding: '0rpx 20rpx',
					height: '60rpx',
					lineHeight: '60rpx',
				},
				logisticsDynamic: {},//最新物流信息
				supplier: {},//区域服务商
				official_account_show: false,//关注公众号弹窗标志
				customerService_show: false,//客服弹窗标志
				customerService_url: "https://www-1308272144.cos.ap-guangzhou.myqcloud.com/BPM/202212/FILE/WechatIMG314P9bi1.jpeg",//客服二维码
				evaluationPicturesArr: []
			}
		},

		onLoad(options) {
			// 未登录跳转到登录页面
			let loginRes = this.checkLogin();
			if (!loginRes) {
				return false;
			}
			
			if(this.isNotNull(options.comeback)){
				this.comeback = options.comeback;
			}
			this.initBackIconName()
			if(this.isNotNull(options.showBtn)){
				this.showBtn = options.showBtn;
			}
			
			/**
			 * 团销通知
			 * 情况2：在团购结束之前已发货，但未确认收货的消费者；
			 * 情况3：在团购结束之前已下单但平台还没有发货的消费者
			 */
			if(this.isNotNull(options.scenario)){
				this.scenario = options.scenario;
			}
			
			if(this.isNotNull(options.recordId)){
				// 获取参与记录(订单)详情
				this.getRecordDetails(options.recordId);
			} else {
				// 兼容之前的记录
				if(this.isNotNull(options.orderId) && this.isNotNull(options.mainDocunid) && this.isNotNull(options.goodsNo)){
					this.getRecordDetails_old(options.orderId, options.mainDocunid, options.goodsNo);
				}
			}
			
			//评价完成后回调
			uni.$on("finishOrder", (orderId) => {
				if(this.isNotNull(orderId)){
					this.getRecordDetails(this.form.id)
				}
			});
		},

		methods: {
			
			/**
			 * uview自定义导航栏返回上一页
			 */
			comeBackCustom(){
				let pages = getCurrentPages()
				if(this.comeback == 1){
					uni.reLaunch({url: '/pages_tabbar_contact/personal_contact/SolitaireList'});
				}else if(pages[pages.length - 2]){
					//如果有上一页，就返回上一页
					this.goBack()
				}else{
					//如果没有上一页，则返回首页
					uni.reLaunch({url:'/pages/index/index'});
				}
			},
			
			/** 
			 * 初始化返回按钮图标
			 */
			initBackIconName() {
				let pages = getCurrentPages()
				if(this.comeback == 1){
					this.backIconName = 'list-dot'
				}else if(pages[pages.length - 2]){
					//如果有上一页，就返回上一页
					this.backIconName = 'nav-back'
				}else{
					//如果没有上一页，则返回首页
					this.backIconName = 'home'
				}
			},

			/**
			 * 获取参与接龙记录的详情
			 */
			async getRecordDetails(recordId){
				let result = await this.$u.api.unifyMiniRest({
					systemid: "meily",
					url: "/buying/getOrderDetails",
					recordId: recordId,
					loading: false // 默认发起请求会有一个全局的Loading，设置false可去掉
				});
				if(result.code == 200){
					this.form = result.data;
					
					if(this.form.partnerId == uni.getStorageSync('userInfo').userId){
						// 当前用户是此订单的消费者
						this.isConsumerOfOrder = true;
					}
					if(this.form.initiatorId == uni.getStorageSync('userInfo').userId){
						// 当前用户是此订单的团长
						this.isCreator = true
					}
					
					if(this.form.address){
						this.addressObj = JSON.parse(this.form.address);
					}
					
					this.title = this.form.orderStatus
					
					// 区域服务商
					if(this.form.supplier){
						this.supplier = JSON.parse(this.form.supplier)
					}
					
					// 评论图片数据，避免页面元素中试用split函数报错
					if(this.form.evaluationPictures){
						this.evaluationPicturesArr = this.form.evaluationPictures.split(',')
					}
					
					//查询物流数据
					this.getLogisticsData(this.form.id)
					
					// 获取商品详情
					this.getGoodsDetails(this.form.goodsId, this.form.goodsNo);
					
					//获取分享进度
					this.getShareProgress();
					
				} else {
					this.showMSG("error", result.msg);
					setTimeout(() => {
						this.goBack()
					}, 2500)
				}
			},
			
			/**
			 * 获取商品详情
			 */
			async getGoodsDetails(goodsId, goodsNo) {
				let result = await this.$u.api.unifyMiniRestGet({
					systemid: "meily",
					url: "/goods/get/" + goodsNo + "/" + goodsId,
				});
				if (result.code == 200) {
					this.goods = result.data; // 商品信息
					// this.getCSInfo(this.goods.helpCsId); // 获取帮卖客服信息
					
					// 计算消费者总分享报酬
					if(this.isNotNull(this.form.buyQuantity) && this.isNotNull(this.goods.consumerShareReward)){
						this.totalShareReward = (Number(this.form.buyQuantity) * parseFloat(this.goods.consumerShareReward)) .toFixed(2);
					}
					
					// 分享组件数据初始化
					this.shareData.docUnid = this.form.mainDocunid;
					
					if(this.form.goodsId == this.form.mainDocunid){
						// 链接到直接购买商品页面
						this.shareData.shareAddress = '/pages_private_scene2/GroupPurchase/DistributionGoods?goodsNo='+this.form.goodsNo+'&goodsId=' + this.form.goodsId;
					} else {
						this.shareData.shareAddress = '/pages_private_scene2/GroupPurchase/SolitaireDetails?docUnid='+this.form.mainDocunid;
					}
					this.shareData.route = this.getCurrentPageUrl(this);
					this.shareData.posterData.imageURL = this.goods.goodsImages.split(',')[0];
					this.shareData.posterData.productName = this.goods.goodsName;
					this.shareData.posterData.productPrice = this.goods.discountPrice;
				}
			},
			
			/**
			 * 获取帮卖客服详情
			 */
			async getCSInfo(helpCsId) {
				let result = await this.$u.api.unifyMiniRestGet({
					systemid: "meily",
					url: "/clientele/get/" + helpCsId,
				});
				if (result.code == 200) {
					this.customerService = result.data;
				}
			},
			
			/** 
			 * 确认收货
			 */
			async ConfirmReceipt() {
				let meilyUrl = "/buying/confirmReceipt";
				if(this.form.mainDocunid == this.form.goodsId){
					// 如果主文档id等于商品id，表示直接购买
					meilyUrl = "/buying/confirmReceipt2";
				}
				let result = await this.$u.api.unifyMiniRest({
					systemid: "meily",
					url: meilyUrl,
					id: this.form.id,
					loading: false // 默认发起请求会有一个全局的Loading，设置false可去掉
				});
				if(result.code == 200){
					this.form = result.data;
					this.title = this.form.orderStatus
					if(this.scenario == '2' || this.scenario == '3'){
						this.scenario_show = true;
					} else {
						this.showMSG("success", result.msg);
					}
					this.automaticReceiptDays = ''
				} else {
					this.showMSG("error", result.msg);
				}
			},

			/**
			 * 前往订单列表
			 */
			async goOrderList() {
				uni.reLaunch({url: "/pages_private_scene2/GroupPurchase/OrderList"});
			},
			
			/**
			 * 前往收益
			 */
			async goToIncomeIndex() {
				uni.reLaunch({url: "/pages/index/incomeIndex"});
			},

			/**
			 * 退换、售后（点击联系客服）
			 */
			AfterSales() {
				if (this.isNotNull(this.customerService.csQrCode)) {
					this.customerService_show = true
				} else {
					this.showMSG('none', '请联系平台管理员')
				}
			},
			
			/**
			 * 点击联系客服
			 */
			async openCustomerServiceChat() {
				let result = await this.$u.api.unifyMiniRestGet({
					systemid: "meily",
					url: "/qyapi/kf/account/url/".concat(globalData.openKfid_afterSales),
					loading: true // 默认发起请求会有一个全局的Loading，设置false可去掉
				});
				if (result.code == 200) {
					const pages = getCurrentPages(); // 获取栈实例
					//当前页面路径(带参数)
					let currentPage = pages[pages.length - 1]['$page']['fullPath']
					let kfUrl = result.data
					wx.openCustomerServiceChat({
						extInfo: {
							url: kfUrl
						},
						corpId: globalData.corpId,
						showMessageCard: true,
						sendMessagePath: currentPage,
						success(res) {
							console.log(res)
						}
					})
				} else {
					this.showMSG('error', '出错啦！');
				}
			},
			
			/**
			 * 生成生成海报
			 */
			async createPoster(docUnid,url,route,type,taskTimes,posterData){
				if(this.form.orderStatus == '已退款'){
					this.showMSG('none','已退款，不可操作！')
					return
				}
				// 根据订单id查询订单记录中是否已经存了海报地址
				let result = await this.$u.api.unifyMiniRest({
					systemid: "meily",
					url: "/buying/getharePictureUrl",
					shareValidationId: this.form.shareValidationId,
					loading: false
				});
				if(result.code == 200){
					this.PosterURL = result.data
					if(!this.isNotNull(this.PosterURL)){
						//将分享记录存入分享表中
						let res = await this.$u.api.unifyRequest({
							appid: 'AppletInterface',
							wf_num: 'R_AppletInterface_BD01',
							path: route,//类型
							loading: true, //默认发起请求会有一个全局的Loading，设置false可去掉
						});
						if(res.code == "200"){
							this.QRID = this.guid()
							const userInfo = uni.getStorageSync('userInfo')
							let result = await this.$u.api.unifyRequest({
								appid: 'ACTIVITY',
								wf_num: 'R_ACTIVITY_BY002',
								url: url,//转向地址
								docUnid: docUnid,
								type: res.type,//类型
								completedTimes: 0,//已完成分享次数
								taskTimes: taskTimes?taskTimes:'',//分享任务数
								rulesImplemented: 0,//是否已经执行完成规则
								naturalKey: this.form.shareValidationId,//业务主键id
								loading: true, //默认发起请求会有一个全局的Loading，设置false可去掉
							});
							if(result.code == "200"){
								this.createCustomPoster(result.scene,docUnid,posterData)
							}else{
								this.showMSG('error',result.msg)
							}
						}
					}else{
						//如果已经存在，直接弹出海报
						this.poster_modal_show = true
					}
				}else{
					this.showMSG('error','出错啦')
				}
			},
			
			/** 
			 * 创建海报
			 */
			async createCustomPoster(scene,docUnid,posterData){
				this.showLoading()
				const userInfo = uni.getStorageSync('userInfo')
				let result = await this.$u.api.unifyMiniRest({
					systemid: "meily",
					url: "/applets/create/poster",
					userId: userInfo.userId,
					nickName: userInfo.nickName,
					avatarUrl: userInfo.avatarUrl,
					imageUrl: posterData.imageURL,
					productName: posterData.productName,
					productPrice: posterData.productPrice,
					pageUrl: 'pages_tabbar_contact/common_contact/guide',
					paramArgs: scene,
					inviteMsg: posterData.invitemsg,
					type: posterData.type,
					giudeText: posterData.giudeText?posterData.giudeText:'',
					priceDesc: posterData.priceDesc?posterData.priceDesc:'',
					loading: true // 默认发起请求会有一个全局的Loading，设置false可去掉
				});
				if(result.code == 200){
					this.PosterURL = result.data
					this.hideLoading()
					if(this.isNotNull(this.PosterURL)){
						//调用接口将海报地址存入订单数据中
						this.addPosterToOrder()
					}else{
						this.showMSG('error','出错啦')
					}
				}else{
					this.showMSG('error','出错啦')
				}
			},
			
			/** 
			 * 调用接口将海报地址存入订单数据中
			 */
			async addPosterToOrder(){
				let result = await this.$u.api.unifyMiniRest({
					systemid: "meily",
					url: "/buying/saveSharePictureUrl",
					shareValidationId: this.form.shareValidationId,
					sharePictureUrl: this.PosterURL,
					loading: false
				});
				if(result.code == 200){
					this.poster_modal_show = true
				}else{
					this.showMSG('error','出错啦')
				}
			},

			
			// toast生成中
			showLoading() {
				wx.showLoading({
				  title: '正在生成中...',
				  icon: 'none',
				});
			},
			 
			hideLoading() {
				wx.hideLoading();
			},
			
			// 长按保存图片
			saveImg(url){
			  //用户需要授权
			  wx.getSetting({
				success: (res) => {
					if (!res.authSetting['scope.writePhotosAlbum']) {
					 wx.authorize({
					  scope: 'scope.writePhotosAlbum',
					  success:()=> {
					   // 同意授权
					   this.saveImg1(url);
					  },
					  fail: (res) =>{
					   console.log(res);
					  }
					 })
					}else{
					 // 已经授权了
					 this.saveImg1(url);
					}
				   },
				   fail: (res) =>{
					console.log(res);
				   }
				})
			},
			
			/**
			 * 保存到相册
			 */
			SaveAlbum(url) {
				wx.getImageInfo({
				   src: url,
				   success:(res)=> {
					let path = res.path;
					wx.saveImageToPhotosAlbum({
					 filePath:path,
					 success:(res)=> { 
					    this.showMSG("success","保存成功！")
					 },
					 fail:(res)=>{
					  console.log("----SaveAlbum fail---")
					  console.log(res);
						this.$u.toast("请点击右上角进入设置并开启添加到相册的权限才能保存到相册噢！")
					 }
					})
				   },
				   fail:(res)=> {
					console.log(res);
				   }
				})
			},
			
			/** 
			 * 复制链接
			 */
			copyLink (link) {
				wx.setClipboardData({
				  //准备复制的数据内容
				  data: link,
				  success: function (res) {
					wx.showToast({
					  title: '已复制',
					});
				  }
				});
			},
			
			/** 
			 * 获取分享进度
			 */
			async getShareProgress(){
				let result = await this.$u.api.unifyRequest({
					appid: 'AppletInterface',
					wf_num: 'R_AppletInterface_BL002',
					shareValidationId: this.form.shareValidationId,
					loading: false // 默认发起请求会有一个全局的Loading，设置false可去掉
				});
				if(result.code == 200){
					this.ShareProgress = result.data
				}else{
					console.log("获取分享进度出错！")
				}
			},
			
			/** 
			 * 跳转到我的订单页面
			 */
			toOrderList() {
				this.$u.route('/pages_private_scene2/GroupPurchase/OrderList')
			},
			
			/** 
			 * 跳转到团购详情
			 * 情况1：自己开团购买，点击跳到自己开团的销售页面；
			 * 情况2：自己参别人的团购买，点击跳转到别人开团的购买页面；
			 */
			goToGroupDetail() {
				this.$u.route('/pages_private_scene2/GroupPurchase/SolitaireDetails?docUnid='+this.form.mainDocunid)
			},
			
			/** 
			 * 点击物流单号跳转到查询物流信息页面
			 */
			toLogisticsInfo() {
				this.$u.route('/pages_tabbar_contact/common_contact/queryLogisticsInfo?id='+this.form.id+'&logisticsModule=GROUPBUY')
			},
			
			/**
			 * 查询物流数据
			 */
			async getLogisticsData(id){
				let result = await this.$u.api.unifyMiniRest({
					systemid: "meily",
					url: "/express/query/realTime/logistics",
					id: id,
					logisticsModule: "GROUPBUY",
					loading: true // 默认发起请求会有一个全局的Loading，设置false可去掉
				});
				if (result.code == 200) {
					if(this.isNotNull(result.data.automaticReceiptDays)){
						let days = Number(result.data.automaticReceiptDays);
						if(days >= 0 && this.form.orderStatus == '待收货'){
							this.automaticReceiptDays = result.data.automaticReceiptDays
						}
					}
					this.logisticsDynamic = result.data.logisticsDynamicList[0]
				}
			},
			
			/** 
			 * 关注公众号弹窗
			 */
			showOfficialAccount() {
				this.official_account_show = true
			},
			
			/**
			 * 关闭公众号弹窗
			 */
			closeOfficialAccount() {
				this.official_account_show = false
			},
			
			/**
			 * 点击“评价”按钮
			 */
			toEvaluate() {
				this.$u.route('pages_private_scene2/GroupPurchase/PostComments?recordId='+this.form.id)
			},
			
			/**
			 * 点击“再来一单”按钮
			 */
			toAnotherOrder() {
				// 跳转到销售机会页面
				this.$u.route('/pages_private_scene2/GroupPurchase/DistributionGoods?goodsNo=' + this.form.goodsNo + '&goodsId=' + this.form.goodsId)
			},
			
			/**
			 * 跳转到销售机会页面
			 */
			async toGoodsDetails(){
				this.$u.route('/pages_private_scene2/GroupPurchase/DistributionGoods?goodsNo=' + this.form.goodsNo + '&goodsId=' + this.form.goodsId);
			}
			
		}
	}
</script>

<style scoped>
	.swiper-item {
		background-color: rgb(240, 240, 240);
	}

	.flex-space-between {
		justify-content: space-between;
	}

	.search-width {
		width: 75%;
	}

	.color-red {
		color: red;
	}

	.content {
		display: flex;
		align-items: center;
	}

	.box {
		width: 95%;
		background-color: #ffffff;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
		border-bottom: 1rpx #e5e5e5 solid;
		margin: 0 auto;
	}

	.aui {
		width: 95%;
		margin: 0 auto;
	}

	.aui-flex {
		display: -webkit-box;
		display: -webkit-flex;
		display: flex;
		-webkit-box-align: center;
		-webkit-align-items: center;
		align-items: center;
		position: relative;
		width: 93%;
		margin: 0 auto;
		height: 120rpx;
		line-height: 120rpx;
		border-bottom: 2rpx solid #f4f4f4;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}
	
	.aui-flex2 {
		display: -webkit-box;
		display: -webkit-flex;
		display: flex;
		-webkit-box-align: center;
		-webkit-align-items: center;
		align-items: center;
		position: relative;
		width: 93%;
		margin: 0 auto;
		height: 85rpx;
		line-height: 85rpx;
		padding-left: 10rpx;
		padding-right: 10rpx;
	}

	.aui-flex-title {
		color: #222;
		font-weight: normal;
		font-size: 1.1rem;
		overflow: hidden;
		width: 75%;
	}

	.aui-flex-box {
		-webkit-box-flex: 1;
		-webkit-flex: 1;
		flex: 1;
		min-width: 150rpx;
		font-size: 30rpx;
		color: #333;
	}

	.aui-flex-box h1 {
		color: #444444;
		font-weight: 500;
		font-size: 1rem;
		overflow: hidden;
		position: relative;
		padding-left: 1rem;
	}

	.aui-flex-box h2 {
		color: #222;
		font-weight: normal;
		font-size: 1.1rem;
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		word-break: break-all;
		text-overflow: ellipsis;
		padding-left: 1rem;
	}

	.aui-flex-box p {
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		word-break: break-all;
		text-overflow: ellipsis;
		font-size: 0.9rem;
		margin-bottom: 0.1rem;
	}

	.cont-red {
		color: red;
	}

	.cont-bold {
		font-weight: bold;
	}

	.cont-small {
		font-size: smaller;
	}

	.cont-gray {
		color: gray;
	}

	.aui-flex-clear {
		padding: 0;
		margin-top: 20rpx;
	}

	.aui-flex-default {
		background: #fff;
	}

	.horizontal-line {
		height: 1rpx;
		background-color: #e0e0e0;
		width: 90%;
		margin: 0 auto;
	}

	.aui-top {
		display: flex;
		justify-content: space-between;
		padding: 30rpx 15rpx 30rpx 30rpx;
	}

	.shop-avatar {
		width: 60rpx;
		height: 50rpx;
		text-align: center;
		padding-right: 10rpx;
	}

	.shop-avatar img {
		width: 100%;
		max-height: 100%;
		vertical-align: top;
		border-radius: 10rpx;
	}

	.u-fb {
		font-weight: bold;
	}

	h3 {
		font-size: 30rpx;
		padding-left: 0
	}

	.h3-limit {
		overflow: hidden;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		word-break: break-all;
		text-overflow: ellipsis;
	}

	.body-title {
		padding: 40rpx 40rpx 15rpx 40rpx;
		font-weight: bold;
	}

	.body-cont {
		padding-left: 40rpx;
		padding-right: 40rpx;
	}

	.conlirow {
		display: flex;
		flex-direction: row;
		align-items: center;
		padding: 0rpx 0rpx 40rpx 0rpx;
	}

	.cont-right {
		display: flex;
		flex-direction: column;
	}

	.cont-right p {
		width: 100%;
	}

	.xmname {
		opacity: 0.7;
		font-family: PingFangSC-Regular;
		font-size: 14px;
		color: #3B353C;
		line-height: 22px;
	}
	
	.name {
		font-family: PingFangSC-Regular;
		font-size: 14px;
		color: #3B353C;
		letter-spacing: 0;
		line-height: 22px;
	}

	.record-bg {
		background-color: #f7f5f5;
	}

	.bg-white {
		background-color: #FFFFFF;
	}

	.body-head {
		display: flex;
		height: 40px;
	}

	.head-icon {
		width: 30px;
	}

	.head-title {
		width: 400px;
		line-height: 80rpx;
	}

	.l-h-1 {
		line-height: 1;
	}

	.p-t-10 {
		padding-top: 10px;
	}

	.f-s-20 {
		font-size: 20px;
	}

	.f-s-10 {
		font-size: 10px;
	}

	.top-area {
		background-color: #f1f0f0;
	}

	.flex-end {
		align-items: flex-end;
	}

	.total-price {
		font-size: 34rpx;
		color: red;
	}

	.border-radius-20 {
		border-radius: 20rpx;
	}
	
	.border-radius-30 {
		border-radius: 30rpx;
	}

	.return-btn {
		display: flex;
		justify-content: space-between;
		padding-right: 30rpx;
	}

	.slot-content {
		font-size: 28rpx;
		color: #a9a9a9;
		text-align: center;
		margin: 0 auto;
	}
	
	.notice-bar {
		background-color: #f7591f;
		color: #ffffff;
		text-align: center;
		height: 80rpx;
		line-height: 80rpx;
		font-size: 24rpx;
		/* position: fixed;
		top: 1;
		left: 0;
		right: 0;
		z-index: 3; */
		width: 100%;
	}
	
	.slot-content3 {
		font-size: 32rpx;
		/* color: #bcbcbc; */
		text-align: left;
		width: 85%;
		margin: 0 auto;
		padding-top: 80rpx;
		padding-bottom: 80rpx;
	}
	.goods-name {
		width: 476rpx;
		overflow: hidden;        /*内容会被修剪，并且其余内容是不可见的*/
		text-overflow:ellipsis;  /*显示省略符号来代表被修剪的文本。*/
		white-space: nowrap;     /*文本不换行*/
	}
	.car-icon {
		width: 45rpx;
		height: 45rpx;
		background-image: url(https://dev-1308272144.cos.ap-guangzhou.myqcloud.com/Meily/GroupPurchase/car-icon.png);
		background-size: 100%;
		color: palegreen;
		margin-right: 20rpx;
	}
	.right-icon {
		text-align: right;
		color: #bcbcbc;
		padding-right: 26rpx;
		position: relative;
	}
	.right-icon::after {
		content: " ";
		display: inline-block;
		height: 18rpx;
		width: 18rpx;
		border-width: 5rpx 5rpx 0 0;
		border-color: #bcbcbc;
		border-style: solid;
		-webkit-transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
		transform: matrix(0.71, 0.71, -0.71, 0.71, 0, 0);
		position: relative;
		top: -2px;
		position: absolute;
		top: 50%;
		margin-top: -4px;
		right: 2px;
		border-radius: 2px;
	}
	.default-tag {
		padding: 0rpx 5rpx;
		background-color: #e5392b;
		color: #ffffff;
		border-radius: 5rpx;
		font-size: 20rpx;
		margin-right: 10rpx;
	}
	.address1 {
		width: 560rpx;
		overflow:hidden;
		text-overflow:ellipsis;
		display:-webkit-box;
		-webkit-box-orient:vertical;
		-webkit-line-clamp:1;
	}
	.aui-flex-goods {
		margin-right: .8em;
		width: 150rpx;
		height: 150rpx;
		line-height: 150rpx;
		text-align: center;
	}
	
	.aui-flex-goods img {
		width: 100%;
		max-height: 100%;
		vertical-align: top;
		border-radius: 15rpx;
	}
	.goods-title {
		width: 470rpx;
		display: -webkit-box;
		/*必须结合的属性,将对象作为弹性伸缩盒子模型显示*/
		-webkit-line-clamp: 1;
		/*设置多少行*/
		-webkit-box-orient: vertical;
		/*必须结合的属性,设置或检索伸缩盒对象的子元素的排列方式*/
		overflow: hidden;
		/*文本会被修剪，并且剩余的部分不可见*/
		text-overflow: ellipsis;
		/*显示省略号来代表被修剪的文本*/
		font-size: 32rpx;
	}
	.aui-flex1 {
		display: flex;
		width: 90%;
		margin: 0 auto;
	}
	.mask-solt {
		display: flex;
		justify-content: center;
		align-items: center;
		height: 100%;
	}
	.official-account-bg {
		background: url(https://www-1308272144.cos.ap-guangzhou.myqcloud.com/Meily/icon/Share/ShareofficialAccount.png) no-repeat;background-size: 100% 100%;
		width: 540rpx;
		height: 780rpx;
	}
	.pictrues-box {
		display: flex;
		flex-wrap: wrap;
		padding-bottom: 40rpx;
	}
	.comment-title {
		height: 100rpx;
		line-height: 100rpx;
		padding-left: 20rpx;
		width: 90%;
		margin: 0 auto;
		border-bottom: 2rpx solid #f4f4f4;
	}
	.goods-specification {
		font-size: 30rpx;
		color: #9f9d9e;
		width: 470rpx;
		display: -webkit-box;
		-webkit-line-clamp: 1;
		-webkit-box-orient: vertical;
		overflow: hidden;
		text-overflow: ellipsis;
	}
	
	.copy-btn {
		color: red;
		text-decoration: underline;
		padding-left: 10rpx;
		font-size: 26rpx;
	}
	
	.order-id {
		width: 450rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}
	
</style>
